#!/bin/sh
# A git hook to block an unsigned-off commit

COMMIT_MSG_FILE=$1

signoff_pattern="Signed-off-by: .+ <.+@.+>"
commit_message="$(cat $COMMIT_MSG_FILE)"

if [[ ! "$commit_message" =~ $signoff_pattern ]]; then
  echo "Aborted \`git commit\` because it's not signed-off."
  echo "You can sign-off your commit using the \`-s\` flag as follows:"
  echo
  echo "git commit -s -m <commit message>"
  exit 1
fi
